$(document).ready(function () { $("a[target='_blank']").addClass("external"); $("a.external").attr("target", "_blank"); $(".icons a[href^='http']").attr("target", "_blank"); $("a[target='_blank']").attr("title", "Opens in a new window") });